<template>
  <div class="all" :style="style">
    <div class="top">
      <div class="left">
        <div class="one"></div>
        <div class="two">{{ title }}</div>
      </div>
      <div class="right">
        <el-button
          type="primary"
          round
          size="medium"
          icon="el-icon-s-home"
          class="btn"
          @click="back"
          >返回主页</el-button
        >
      </div>
    </div>
    <div class="main">
      <slot name="content"></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: "Common",
  props: {
    title: {
      type: String,
      default: "",
    },
  },
  components: {},
  data() {
    return {
      bgStyle: require("@/assets/backgd.png"),
    };
  },
  computed: {
    style() {
      return {
        backgroundImage: `url(${this.bgStyle})`,
        backgroundSize: "cover", // 背景图片大小自适应
        backgroundPosition: "center", // 背景图片居中显示
      };
    },
  },
  watch: {},
  created() {},
  methods: {
    back() {
      let room = localStorage.getItem("room");
      window.location.replace(`/#/main?room=${room}`);
      // this.$router.back();
    },
  },
};
</script>


<style lang="scss" scoped>
.all {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  .top {
    padding: 20px;
    display: flex;
    align-items: center;
    .left {
      display: flex;
      align-items: center;
      .one {
        background-color: #009191;
        width: 14px;
        height: 30px;
      }
      .two {
        font-size: 24px;
        color: #009191;
        font-weight: bold;
        margin-left: 10px;
      }
    }
    .right {
      margin-left: auto;
    }
  }
  .main {
    flex: 1;
  }
}
</style>
